﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

namespace RoomService.Listings
{
    public partial class Post : System.Web.UI.Page
    {
        SqlConnection con = new SqlConnection("Server=tcp:w51ynzfjnq.database.windows.net,1433;Database=gsuhousing;User ID=student042@w51ynzfjnq;Password=Vtre5$2cgs;Trusted_Connection=false;Encrypt=True;Connection Timeout=30;");
        
        protected void Page_Load(object sender, EventArgs e)
        {
            con.Open();

        }

        protected void itemSelected(object sender, EventArgs e)
        {
      
            // con.Open();
           /* SqlCommand cmd = new SqlCommand("SELECT . FROM [Apartment]", con);
            try
            {
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {

            }

            con.Close();*/
            paddress1.Text = "test";
            paddress2.Text = "test2";
            pcity.Text = "test3";
            pstate.Text = "test4";
            pzip.Text = "test5";
        }

        private void Page_Init(Object sender, EventArgs e)
        {
            btnPost.Click += new EventHandler(this.Post_Click);

        }
        protected void Post_Click(Object sender, EventArgs e)
        {
           // con.Open();


            String values = "(" + 345676 + ", " + Convert.ToInt32(prent.Text) + "," + Convert.ToInt32(ptotbeds.SelectedValue) + ", " + Convert.ToString(pbathtype.SelectedValue) + "," + Convert.ToString(pbathtype.SelectedValue) +", '10-12-34'," + 9999 +","+ 9999 +"," + 708 +"," + Convert.ToString(ptitle)+")";
            String query = "Insert into Listings (Listing#, Rent, TotalBeds, AvlBeds, BathType, StartDate, MemID, UserID, AptID, Title) Values  (54674, 400, 4, 3, 'Shared', '10-12-34', 999, 999, 708, Title) Values" + values;
            SqlCommand cmd = new SqlCommand(query,con);
           try {
               cmd.ExecuteNonQuery();
           
           }
           catch (Exception ex) {
               
           }

           values = "(" + 345676 + ", " + Convert.ToInt32(prent.Text) + "," + Convert.ToInt32(ptotbeds.SelectedValue) + ", " + Convert.ToString(pbathtype.SelectedValue) + "," + Convert.ToString(pbathtype.SelectedValue) + ", '10-12-34'," + 9999 + "," + 9999 + "," + 708 + "," + Convert.ToString(ptitle) + ")";
           String query = "Insert into Listings (Listing#, Rent, TotalBeds, AvlBeds, BathType, StartDate, MemID, UserID, AptID, Title) Values  (54674, 400, 4, 3, 'Shared', '10-12-34', 999, 999, 708, Title) Values" + values;
           cmd = new SqlCommand(query, con);
           try
           {
               cmd.ExecuteNonQuery();

           }
           catch (Exception ex)
           {

           }

           values = "(" + 345676 + ", " + Convert.ToInt32(prent.Text) + "," + Convert.ToInt32(ptotbeds.SelectedValue) + ", " + Convert.ToString(pbathtype.SelectedValue) + "," + Convert.ToString(pbathtype.SelectedValue) + ", '10-12-34'," + 9999 + "," + 9999 + "," + 708 + "," + Convert.ToString(ptitle) + ")";
           query = "Insert into Listings (Listing#, Rent, TotalBeds, AvlBeds, BathType, StartDate, MemID, UserID, AptID, Title) Values  (54674, 400, 4, 3, 'Shared', '10-12-34', 999, 999, 708, Title) Values" + values;
          cmd = new SqlCommand(query, con);
           try
           {
               cmd.ExecuteNonQuery();

           }
           catch (Exception ex)
           {

           }

            
            con.Close();
    




        }

    }
}

